/*Source

Problem Id:2703  User Id:Latex 
Memory:76K  Time:171MS
Language:G++  Result:Accepted

Source 
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>

	struct rectype
	{
		int w, h;
	} rec[2100], sets[210][2];
	int nset;
	int sum;
	int n;

int mycompr(const void *arg1, const void *arg2)
{
	struct rectype *a, *b;
	
	a = (struct rectype *) arg1;
	b = (struct rectype *) arg2;
	if (a->w != b->w) return (b->w - a->w);
	
	//if (a->w == b->w)
	return (b->h - a->h);
}

int main()
{
	int  i, j, k;
	int  x, y, ax, ay, bx, by;
	int  incr_a, incr_b;
	int  lastw, first;
	
	//freopen("j.in", "r", stdin);
	//freopen("j.out", "w", stdout);
	
	while (scanf("%ld", &n),n > 0)
	{
		for (i=1; i<=n; i++)
		{
			scanf("%ld%ld", &(rec[i].w), &(rec[i].h));
			if (rec[i].w > rec[i].h)
			{
				k = rec[i].w;
				rec[i].w = rec[i].h;
				rec[i].h = k;
			}
		}
		qsort(rec+1, n, sizeof(struct rectype), mycompr);
		//w from longest to shortest
		//when w equal : h from longest to shortest
		
		nset = 0;
		lastw = 0;
		first = true;
		for (i=1; i<=n; i++)
		{
			if (first || rec[i].w != lastw)
			{
				first = false;
				nset++;
				sets[nset][0] = rec[i];
				i++;
				sets[nset][1] = rec[i];
				lastw = rec[i].w;
			}
		}
		
		sum = sets[1][0].w * sets[1][0].h + sets[1][1].w * sets[1][1].h - sets[1][0].w * sets[1][1].w;
		x = sets[1][0].h;
		y = sets[1][1].h;
		
		for (i=2; i<=nset; i++)
		{
			//solution a
			incr_a = 0;
			if (sets[i][0].h > x) 
			{
				incr_a += (sets[i][0].h - x) * sets[i][0].w;
				ax = sets[i][0].h;
			} else ax = x;
			if (sets[i][1].h > y)
			{
				incr_a += (sets[i][1].h - y) * sets[i][1].w;
				ay = sets[i][1].h;
			} else ay = y;
			
			//solution b
			incr_b = 0;
			if (sets[i][0].h > y) 
			{
				incr_b += (sets[i][0].h - y) * sets[i][0].w;
				by = sets[i][0].h;
			} else by = y;
			if (sets[i][1].h > x)
			{
				incr_b += (sets[i][1].h - x) * sets[i][1].w;
				bx = sets[i][1].h;
			} else bx = x;
			
			if (incr_a > incr_b)
			{
				sum += incr_a;
				x = ax;
				y = ay;
			} else
			{
				sum += incr_b;
				x = bx;
				y = by;
			}
			
			//debug
			//printf("inc_a = %ld incr_b = %ld\n", incr_a, incr_b);
		}
		printf("%ld\n", sum);
	}
	return 0;
}


